package com.itheima.health.utils;


import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.locks.InterProcessMutex;
import org.apache.curator.retry.RetryNTimes;

public class ZkLockUtil {

    private CuratorFramework client = null;

    public InterProcessMutex getZkLock(){
        RetryPolicy retryPolicy = new RetryNTimes(10,1000);
        client = CuratorFrameworkFactory.newClient("121.4.52.55:2181", retryPolicy);
        client.start();
        return new InterProcessMutex(client,"/order/1/update");
    }


    public void closeZkLock(){
        client.close();
    }
}
